import { bdlMgr } from "db://assets/Script/Manager/BundleManager_S";
// import { ResourceUtilClass } from "./resourceUtilClass";
import { JsonAsset, Node } from "cc";

export class GameData {
    private static instance: GameData = null!;

    public static getInstance() {
        if (this.instance === null) {
            this.instance = new GameData();
        }
        return this.instance;
    }

    // 当前残局
    public matchId: number = 0;

    public rootNode: Node = null!;//根节点

    //配置数据
    public match_data!: any;

    private isConfigLoad: boolean = false;

    public async loadConfig() {
        if (!this.isConfigLoad) {
            // this.match_data = (await ResourceUtilClass.loadTheRes("config/match_data", JsonAsset) as JsonAsset).json!;
            this.match_data = (await bdlMgr.getRes<JsonAsset>(`Xiangqi_json`, `match_data`, JsonAsset) as JsonAsset).json!;
            console.log("match_data", this.match_data);
        }
    }
}
